home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / rexx / imc / rexx-imc.5a / rexx.summary < prev    next >
Encoding:
Text File  |  1993-09-05  |  12.3 KB  |  294 lines

  1.  
  2. The REXX Summary
  3.  
  4. Summary of the summary
  5.  
  6.  * Section 1: Differences from TRL [1]
  7.  * Section 2: Summary of expression syntax
  8.  * Section 3: Summary of instructions
  9.  * Section 4: Summary of builtin functions
  10.  
  11. [1] The Rexx Language, a practical approach to programming
  12.     M. F. Cowlishaw
  13.     Englewood Cliffs 1985
  14.  
  15. 1 Differences from TRL
  16.  
  17. The following are all nonstandard features of REXX-imc
  18.  
  19.  * Rejection of labels ending with dot (in case of confusion between
  20.    function.(args) and stem.(tail))
  21.  * Compound variable accesses of the form "stem.'string constant'" and
  22.    stem.(expression)
  23.  * Acceptance of any non-zero number for logical truth, rather than just 1
  24.  * "SAYN expression" to output lines without carriage return
  25.  * "SELECT expression" to switch on a value
  26.  * "END SELECT"
  27.  * "PARSE VALUE" with multiple strings separated by commas
  28.  * "PROCEDURE HIDE"
  29.  * The following functions: chdir getcwd getenv putenv system userid
  30.    plus these I/O functions: open close fdopen popen pclose fileno ftell
  31.  * error messages 80-210, -1 and -3.
  32.  
  33. 2 Summary of expression syntax
  34.  
  35. Strings:          "String constants" 'enclosed in quotes'
  36. Hex strings:      '616263 64'x
  37. Numbers:          123.4e-56
  38. Constant symbols: .abc 1d4 7!
  39. Simple symbols:   foo bar xyz3
  40. Stems:            array.
  41. Compound symbols: c.3 element.bar.45
  42. Operators:        arithmetic: + - * / ** (to-power) % (div) // (mod)
  43.                   string:     [abuttal] [space] || (concatenation)
  44.                   logical:    \ (not) & (and) | (or) && (xor)
  45.                   comparison: = > < <> <= >= \> \< \=
  46.                               == >> << <<= >>= \>> \<< \== (strong comparison)
  47. Function calls:   fn(1,2,3)    bar(,5)  'DATE'()
  48.  
  49. 3 Summary of instructions
  50.  
  51. /* this is a comment */
  52.  
  53. expression                     - execute a host command
  54.  
  55. symbol=value                   - assignment
  56.  
  57. ADDRESS [VALUE] [environment]  - change the current environment
  58. ADDRESS environment command    - execute a command in an environment
  59.  
  60. CALL name [arg][,[arg],...]]   - call a function or subroutine
  61. CALL ON condition [NAME symbol]- turn on condition handling
  62. CALL OFF condition             - turn off condition handling
  63.  
  64.     condition = ERROR | FAILURE | NOTREADY | HALT
  65.  
  66. DO [ symbol=start   [TO  finish]  ]     [WHILE expression_w]
  67.    [                [BY  step  ]  ]
  68.    [                [FOR count ]  ]     [UNTIL expression_u]
  69.  
  70.    [ expression_c                 ]     [FOREVER           ]
  71.  
  72.                                - block or repetitive block instruction
  73.  
  74. DROP symbol [symbol...]        - de-assignment
  75.  
  76. END [symbol]                   - end block or repetitive block instruction
  77.  
  78. EXIT [expression]              - exit program or external function
  79.  
  80. IF expression [;] THEN [;] statement [ ; ELSE [;] statement]
  81.                                - conditional instruction
  82.  
  83. INTERPRET expression           - dynamically execute a string
  84.  
  85. ITERATE [symbol]               - continue repetitive block
  86.  
  87. LEAVE [symbol]                 - leave repetitive block
  88.  
  89. NOP                            - do nothing
  90.  
  91. NUMERIC DIGITS n               - set parameters for numeric formatting
  92. NUMERIC FUZZ n
  93. NUMERIC FORM   SCIENTIFIC
  94.              | ENGINEERING
  95.              | "string constant"
  96.              | [VALUE] expression
  97.  
  98. OPTIONS expression             - Control system-dependent things
  99.  
  100. [PARSE [UPPER]] ARG template   
  101. [PARSE [UPPER]] PULL [template]
  102. PARSE [UPPER] LINEIN [template]
  103. PARSE [UPPER] SOURCE template
  104. PARSE [UPPER] VERSION template
  105. PARSE [UPPER] NUMERIC template
  106. PARSE [UPPER] VAR symbol template
  107. PARSE [UPPER] VALUE expression WITH template
  108.  
  109.     template        -> [firstPosition] assignments [assignments]
  110.     assignments     -> [nextPosition] varlist [stopPosition]
  111.     varlist         -> varname ' ' [varlist]
  112.     varname         ->   "non-constant symbol"
  113.                        | '.'
  114.     firstPosition   -> position
  115.     nextPosition    -> position [nextPosition]
  116.     stopPosition    -> position
  117.     position        ->   searchPosition
  118.                        | absPosition
  119.                        | relPosition
  120.                        | '(' "expression" ')'
  121.     searchPosition  -> "string constant"
  122.     absPosition     ->   "integer"
  123.                        | '=' numexpr
  124.     relPosition     ->   '+' numexpr
  125.                        | '-' numexpr
  126.     numexpr         ->   "integer"
  127.                        | '(' "integer expression" ')'
  128.  
  129. PROCEDURE                      - hide the caller's symbols
  130. PROCEDURE EXPOSE var1 [var2...]
  131. PROCEDURE HIDE var1 [var2...]
  132.  
  133. PUSH  expression               - stack a value in LIFO order
  134. QUEUE expression               - stack a value in FIFO order
  135.  
  136. RETURN [value]                 - return from a function or subroutine
  137.  
  138. SAY [expression]               - echo data
  139. SAYN expression                - echo data without newline
  140.  
  141. SELECT [expression]
  142.    WHEN expression THEN statements
  143.    WHEN expression THEN statements
  144.    ...
  145.    [OTHERWISE statements]
  146. END [SELECT]                   - switch on a list of conditions
  147.  
  148. SIGNAL [VALUE] name            - jump to a label
  149. SIGNAL ON condition [NAME symbol] - turn on condition handling
  150. SIGNAL OFF condition              - turn off condition handling
  151.  
  152.     condition = ERROR | FAILURE | NOTREADY | HALT | SYNTAX | NOVALUE
  153.  
  154. TRACE [symbol]                 - control program tracing. Values are:
  155. TRACE "string"                   A (all clauses) C (commands) E (error)
  156. TRACE VALUE expression           F (failure) I (intermediate values)
  157.                                  L (labels) N (normal, =F) O (off) 
  158.                                  R (results)
  159.  
  160.  
  161. 4 Summary of builtin functions
  162.  
  163. Standard functions
  164.  
  165. ABBREV(information,info[,length])  - check for valid abbreviations
  166. ABS(number)                        - return the absolute value
  167. ADDRESS()                          - return the current environment
  168. ARG([n][,opt])                     - return or test an argument
  169. BITAND(string1,string2[,pad])
  170. BITOR (string1,string2[,pad])      - combine two strings with bit operations
  171. BITXOR(string1,string2[,pad])
  172. B2D(binary)
  173. B2X(binary)
  174. D2B(decimal)
  175. C2X(string)
  176. C2D(string[,n])
  177. D2C(decimal[,n])                   - convert between data formats
  178. D2X(decimal[,n])
  179. X2B(hex)
  180. X2C(hex)
  181. X2D(hex)
  182. CENTER(s,n[,pad])                  - centre a string in a field
  183. CENTRE(s,n[,pad])
  184. COMPARE(s1,s2[,pad])               - compare two strings
  185. CONDITION([option])                - return information about trapped condition
  186.                                      Option can be (default I):
  187.                                    C (condition name) D (description)
  188.                                    I (instruction)    S (status)
  189.                                    
  190. COPIES(s,n)                        - replicate a string
  191. DATATYPE(string[,type])            - test datatype. Type can be:
  192.                                    A (alphanumeric) B (bits) L (lowercase)
  193.                                    M (mixed case) N (number) S (symbol chars)
  194.                                    U (upper case) W (whole number) X (hex)
  195.  
  196. DATE([format])                     - get date. Format can be:
  197.                                    B (base date - days since 1/1/1 AD)
  198.                                    C (days in century) D (days in year)
  199.                                    E (European) J (Julian) M (month name)
  200.                                    N (normal: dd Mon yyyy) O (ordered)
  201.                                    S (sorted) U (USA) W (day of week)
  202.                                    
  203. DELSTR(string,n[,length])          - delete substring
  204. DELWORD(string,n[,length])         - delete words
  205. DIGITS()                           - NUMERIC DIGITS setting
  206. ERRORTEXT(i)                       - Rexx error message
  207. FORM()                             - NUMERIC FORM setting
  208.  
  209. FORMAT(number [,[before] [,[after] [,[expp] [,expt]]]] )
  210.                                    - format a number as specified
  211. FUZZ()                             - NUMERIC FUZZ setting
  212. INSERT(new,target[,[n][,[length][,pad]]])  - insert new string into target
  213. JUSTIFY(s,n[,pad])                 - justify text to given width
  214. LASTPOS(needle,haystack[,start])   - find last occurrence of a string
  215. LEFT(string,num[,pad])             - return an initial substring
  216. LENGTH(string)                     - find the length of a string
  217. LINESIZE()                         - find the terminal width
  218. MAX(number[,number...])            - find the maximum of a set
  219. MIN(number[,number...])            - find the minimum of a set
  220. OVERLAY(new,target[,[n][,[length][,pad]]])  - overlay new string on to target
  221. POS(needle,haystack[,start])       - find the first occurance of a string
  222. QUEUED()                           - return the number of items on the stack
  223. RANDOM([min][,[max][,seed]])       - return a random number
  224. REVERSE(string)                    - find the reverse of a string
  225. RIGHT(string,num[,pad])            - return a final substring
  226. SOURCELINE([i])                    - return a line of the source program
  227. SPACE(s[,[n][,pad]])               - evenly space words in a sentence
  228. STRIP(string[,[opt][,char]])       - remove leading/trailing spaces
  229. SUBSTR(string,n[,length[,pad]])    - return a substring
  230. SUBWORD(string,n[,k])              - return a substring of words
  231. SYMBOL(name)                       - test to see if a symbol is defined
  232. TIME([format])                     - get the time. Format can be:
  233.                                    C (civil time) N (normal) L (long)
  234.                                    H (hours since midnight)
  235.                                    M (minutes since midnight)
  236.                                    S (seconds since midnight) E (elapsed time)
  237.                                    R (elapsed time then reset)
  238.                                    
  239. TRACE([setting])                   - get and/or set trace mode (see trace
  240.                                      instruction)
  241.                                      
  242. TRANSLATE(string[,[tableo][,[tablei][,pad]]])
  243.                                    - translate characters using given tables
  244. TRUNC(number[,n])                  - truncate floating point number
  245. VALUE(s[,[newvalue][,selector]])   - get or set value of a symbol
  246.  
  247. VERIFY(string,reference[,[option][,start]])
  248.                                    - verify string for valid characters
  249. WORD(string,n)                     - return a word from a string
  250. WORDINDEX(string,n)                - return the position of a word in a string
  251. WORDLENGTH(string,n)               - return the length of a word in a string
  252. WORDPOS(phrase,string[,start])     - find a phrase in a string 
  253. WORDS(string)                      - return the number of words in a string
  254. XRANGE([a[,b]])                    - return a range of characters
  255.  
  256. I/O functions (some of which are UNIX-specific)
  257.  
  258. CHARIN([stream] [,[position] [,count]])  - read characters
  259. CHAROUT([stream] [,[string] [,position] ]- write characters
  260. CHARS([stream])                          - number of characters available
  261. CLOSE(stream)                            - close a stream
  262. FDOPEN(fd [,[mode] [,stream]])           - open an fd number
  263. FILENO(stream)                           - find an fd number
  264. FTELL(stream)                            - return the current file pointer
  265. LINEIN([stream] [,[line] [,count]])      - read a line
  266. LINEOUT([stream] [,[string] [,line]])    - write a line
  267. LINES([stream])                          - determine whether lines may be read
  268. OPEN(file [,[mode] [,stream]])           - open a file
  269. PCLOSE(stream)                           - close a pipe
  270. POPEN(command [,[mode] [,stream]])       - open a pipe to a shell command
  271. STREAM(stream [,[option] [,command]])    - miscellaneous stream operations
  272.  
  273. UNIX-specific functions
  274.  
  275. CHDIR(directory)                   - change to new directory
  276. GETCWD()                           - return current working directory
  277. GETENV(name)                       - get an environment variable
  278. PUTENV(string)                     - set an environment variable
  279. SYSTEM(s)                          - return the output of a shell command
  280. USERID()                           - return the process owner's login name
  281.  
  282. Mathematical functions (implemented as separate package)
  283.  
  284. ACOS(x)      the arc-cosine of x in radians (0<=acs(x)<=pi)
  285. ASIN(x)      the arc-sine of x in radians (-pi/2<=asn(x)<=pi/2)
  286. ATAN(x)      the arc-tangent of x in radians (-pi/2<=atn(x)<=pi/2)
  287. COS(x)       the cosine of x radians
  288. EXP(x)       the exponential of x (2.718281... to the power x)
  289. LN(x)        the natural logarithm of x (x>0)
  290. SIN(x)       the sine of x radians
  291. SQRT(x)      the square root of x (x>=0) [arbitrary precision possible]
  292. TAN(x)       the tangent of x radians (x <> pi/2)
  293. TOPOWER(x,y) x to the power y
  294.